#ifndef CHOOSEFRIENDWIDGET_H
#define CHOOSEFRIENDWIDGET_H

#include <QDialog>
#include <QWidget>
#include <QHBoxLayout>
#include <QCheckBox>
#include <QLabel>


/////////////////////////////
// 创建一个公用的item表示一个用户
/////////////////////////////

class chooseFriendWidget;

class selectFriendItem : public  QWidget
{
    Q_OBJECT
public:
    selectFriendItem(chooseFriendWidget* owner, const QString& userId, const QIcon& icon, const QString& name, bool isSelected);
    void paintEvent(QPaintEvent *event) override;
    void enterEvent(QEnterEvent* event) override;
    void leaveEvent(QEvent* event) override;
    const QString getUserId() const;
    void setStatus(bool status);

private:
    bool isEnter;
    QCheckBox* checkBox;
    QPushButton* avatarBtn;
    QLabel* nameLabel;
    chooseFriendWidget* owner;
    QString userId;
};



/////////////////////////////
// 选择用户界面
/////////////////////////////


class chooseFriendWidget : public QDialog
{
    Q_OBJECT
public:
    chooseFriendWidget(QWidget* parent);
    void initLeft(QHBoxLayout* layout);
    void initRight(QHBoxLayout* layout);

    void addFriend(const QString& userId, const QIcon& icon, const QString& name);
    void addSelectedFriend(const QString& userId, const QIcon& icon, const QString& name);
    void deleteSelectedFriend(const QString& userId);
private:
    QWidget* friendWidget;
    QWidget* selectedFriendWidget;
};

#endif // CHOOSEFRIENDWIDGET_H
